package com.wgh.api.client.cart;

import com.wgh.api.client.fallback.CartClientFallback;
import com.wgh.cart.dto.CartItemDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 购物车服务客户端接口
 */
@FeignClient(name = "shop-cart", fallback = CartClientFallback.class)
public interface CartClient {

    /**
     * 添加商品到购物车
     */
    @PostMapping("/cart/add")
    Boolean addToCart(@RequestBody CartItemDTO cartItemDTO);

    /**
     * 获取用户购物车列表
     */
    @GetMapping("/cart/list")
    List<CartItemDTO> getCartList(@RequestParam("userId") Long userId);

    /**
     * 更新购物车商品数量
     */
    @PutMapping("/cart/update")
    Boolean updateCartItemCount(@RequestBody CartItemDTO cartItemDTO);

    /**
     * 删除购物车商品
     */
    @DeleteMapping("/cart/delete")
    Boolean deleteCartItem(@RequestParam("id") Long id);

    /**
     * 清空购物车
     */
    @DeleteMapping("/cart/clear")
    Boolean clearCart(@RequestParam("userId") Long userId);

    /**
     * 批量获取购物车商品
     */
    @GetMapping("/cart/batch")
    List<CartItemDTO> getBatchCartItems(@RequestParam("ids") List<Long> ids);
}